<?php
header('Content-type:text/html;charset=utf-8');

//包含数据库配置
include '../../public/peizhi.php';

//包含函数
include '../../public/func.php';

//调用函数
$link = db();

//接值
$fq_id = $_POST['fq_id'];

$bk_name = $_POST['bk_name'];


//判断分区名字长度
if(empty(strlen($bk_name)) || strlen($bk_name) > 20){
	exit('<script>alert("没有板块名称或板块名称超过20字");window.location.href="add.php";</script>');
}

//准备SQL语句
$sql = "insert into bankuai(fq_id,bk_name) values('{$fq_id}','{$bk_name}')";

//执行SQL语句
if($res = mysqli_query($link,$sql)){
	echo '<script>alert("添加板块成功");window.location.href="show.php";</script>';
}else{
	echo '<script>alert("添加板块失败");window.location.href="add.php";</script>';
}

//关闭数据库连接
mysqli_close($link);


